package com.easylinkin.linkappapi.positioning.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easylinkin.linkappapi.common.model.RequestModel;
import com.easylinkin.linkappapi.positioning.entity.PositionAlarmInfo;
import com.easylinkin.linkappapi.positioning.entity.QueryAlarm;
import com.easylinkin.linkappapi.positioning.service.PositionAlarmService;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;

/**
 * class info :告警信息列表（车辆定位）
 *
 * @author liuqihang
 * @date 2021/7/26 12:01
 */
@RestController
@RequestMapping("/position/alarm")
public class PositionAlarmController {

    @Resource
    private PositionAlarmService positionAlarmService;

    @PostMapping("getPage")
    public RestMessage getPage(@RequestBody RequestModel<QueryAlarm> requestModel) throws Exception {
        Assert.notNull(requestModel.getCustomQueryParams(), "customQueryParams 不能为空");
        Assert.notNull(requestModel.getPage(), "page 不能为空");
        IPage<PositionAlarmInfo> detailPage = positionAlarmService.getPage(requestModel.getPage(), requestModel.getCustomQueryParams());
        return RestBuilders.successBuilder().data(detailPage).build();
    }

}
